package org.gruposp2p.aula.gwt.client;

import org.gruposp2p.aula.gwt.client.content.AulaContentPanelManager;
import org.gruposp2p.aula.gwt.client.content.AulaTitlePanelManager;
import org.gruposp2p.aula.gwt.client.content.AulaTopPanelManager;
import org.gruposp2p.aula.gwt.client.content.GlassedDialog;
import org.gruposp2p.aula.gwt.client.model.AulaUser;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.Constants;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * <p>
 * A generic application that includes a title bar, main menu, content area, and
 * some external links at the top.
 * </p>
 * <h3>CSS Style Rules</h3>
 * 
 * <ul class="css">
 * 
 * <li>.AulaApplication { Applied to the entire Application }</li>
 * 
 * <li>.AulaApplication-top { The top portion of the Application }</li>
 * 
 * <li>.AulaApplication-title { The title widget }</li>
 * 
 * <li>.AulaApplication-links { The main external links }</li>
 * 
 * <li>.AulaApplication-options { The options widget }</li>
 * 
 * <li>.AulaApplication-menu { The main menu }</li>
 * 
 * <li>.AulaApplication-content-wrapper { The scrollable element around the content }</li>
 * 
 * </ul>
 */
public class AulaApplication extends Composite {
	
	public static final AulaImages images = (AulaImages) GWT.create(AulaImages.class);	
	
   /**
	* The panel that contains the title widget and links.
	*/
	private FlexTable topPanel;	
	
	private FlowPanel mainLayout;
	
	private AulaConstants constants;
	
	private AulaUser aulaUser; 
	
	public static interface AppConstants extends Constants {}

   /**
	* Constructor.
	*/
	public AulaApplication() {
		constants = (AulaConstants) GWT.create(AulaConstants.class);
		GlassedDialog.getInstance().initData(this);
	    // Setup the main layout widget
		mainLayout = new FlowPanel();
	    initWidget(mainLayout);
	    // Setup the top panel with the title and links
	    AulaTopPanelManager aulaTopPanel = new AulaTopPanelManager (this);
	    mainLayout.add(aulaTopPanel.createWidget());
	    AulaTitlePanelManager aulaTitlePanelManager = 
	    	new AulaTitlePanelManager (this);
	    mainLayout.add(aulaTitlePanelManager.createWidget());
	    AulaContentPanelManager aulaContentPanelManager =
	    	new AulaContentPanelManager (this);
	    mainLayout.add(aulaContentPanelManager.createWidget());
	    
/*
	    HorizontalPanel bottomPanel = new HorizontalPanel();
	    bottomPanel.setWidth("100%");
	    bottomPanel.setSpacing(0);
	    bottomPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
	    mainLayout.add(bottomPanel);*/	    
	  }	  
	
	  /**
	   * Set the {@link Widget} to use as the title bar.
	   * 
	   * @param title the title widget
	   */
	  public void setTitleWidget(Widget title) {
	    topPanel.setWidget(1, 0, title);
	  }	

	  
	  /**
	   * Create the title bar at the top of the application.
	   * 
	   * @param constants the constant values to use
	   */
	  private void setupTitlePanel() { }
	  
	  public AulaConstants getConstants () {
		  return constants;
	  }	 
	  
	  public AulaUser getAulaUser () {
		  return aulaUser;
	  }
	  
	  public void setAulaUser (AulaUser aulaUser) {
		  this.aulaUser = aulaUser;
	  }	  

	  public AulaImages getImages () {
		  return images;
	  }

}
